<template>
  <div v-if="route.fullPath !== '/login'">
    <!-- todo 动态标题 -->
    <van-nav-bar class="navbar" title="标题" left-text="返回" left-arrow @click-left="onClickLeft">
      <template #right>
        <van-icon name="search" size="18" @click="onClickRight" />
      </template>
    </van-nav-bar>

    <div id="content">
      <router-view />
    </div>

    <van-tabbar route>
      <van-tabbar-item to="/" icon="home-o">主页</van-tabbar-item>
      <van-tabbar-item to="/team" icon="search">队伍</van-tabbar-item>
      <van-tabbar-item to="/mine" icon="friends-o">个人</van-tabbar-item>
    </van-tabbar>
  </div>
  <div v-else>
    <router-view />
  </div>
</template>

<script setup lang="ts">
import { useRouter, useRoute } from 'vue-router'

const router = useRouter()
const route = useRoute()

const onClickLeft = () => {
  router.back()
}
const onClickRight = () => {
  router.push({ path: '/search' })
}
</script>

<style scoped>
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}
#content {
  padding: 46px 0 50px;
}
</style>
